
package com.cusro.sesion3;

import java.util.Random;

import javax.swing.JOptionPane;

public class Ejemplo5c {

	/*

public static final int LUNES = 1;
 public static final int MARTES = 2;
 public static final int MIERCOLES = 3;
 public static final int JUEVES = 4;
 public static final int VIERNES = 5;
 public static final int SABADO = 6;
 public static final int DOMINGO = 7;
	 */
	public enum Dias {
		LUNES(1,"Monday"), MARTES(2,"thuesday"), MIERCOLES(3,"wednesday"), 
		JUEVES(4,"thursday"), VIERNES(5,"friday"), SABADO(6,"saturday"), DOMINGO(7,"sunday");

		private int orden;
		private String english;

		Dias(int orden, String english){
			this.orden=orden;
			this.english=english;	
		}
		public int getOrden(){
			return this.orden;
		}
		public String getEnglish(){
			return this.english;
		}
		public static Dias findDay(int orden){
			// creacion de arreglos 
			Dias[] values = Dias.values(); // control + 1 da un arreglo de la sentencia, el values devuelve a los 7 dias de la semana
			for (int i = 0; i < values.length; i++) { 
				Dias dia = values[i];
				if (dia.getOrden() ==orden){
					return dia;
				}
			}
			return null;
		}
		public static  Dias [] getAll(){
			return Dias .values();
		}
		public static String getAllForYou(){
			Dias[] values = Dias.values() ;
			String cosa = new  String ();
			for (int i = 0; i < values.length; i++) {
				Dias dias = values[i];
				cosa = cosa += dias.getEnglish()+ "\t";	
			}
			return cosa;
		}

		/**
		 * @param args
		 */
		public static void main(String[] args) {

			int dia = Integer.parseInt(JOptionPane.showInputDialog("Ingrese un numero de 1 a 7"));
			// creacion de la variable
			Random aleatorio= new Random ();
			int x = aleatorio.nextInt(7);

			Dias algundia = Dias. findDay(x);

			JOptionPane.showMessageDialog(null, "Tenemos estos dias: "+Dias.getAllForYou()+" y ademas genero el dia "+x);

			switch(algundia) {

			case LUNES: 
				JOptionPane.showMessageDialog(null, "Su dia es Lunes");
				break;
			case MARTES: 
				JOptionPane.showMessageDialog(null, "Su dia es Martes");
				break;
			case MIERCOLES: 
				JOptionPane.showMessageDialog(null, "Su dia es Miercoles");
				break;
			case JUEVES: 
				JOptionPane.showMessageDialog(null, "Su dia es Jueves");
				break;
			case VIERNES: 
				JOptionPane.showMessageDialog(null, "Su dia es Viernes");
				break;
			case SABADO: 
				JOptionPane.showMessageDialog(null, "Su dia es Sabado");
				break;
			case DOMINGO: 
				JOptionPane.showMessageDialog(null, "Su dia es Domingo");
				break;
			default:
				JOptionPane.showMessageDialog(null, "Ingreso un un valor incorrecto");
			}

		}

	}

}